/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package PIII.Negocio;

/**
 *
 * @author sistemas
 */
import Dal.TDatos_sql;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Rubro extends TDatos_sql {

    public Rubro() throws SQLException {
    }

    public String getNombreRubro() {
        return NombreRubro;
    }

    public void setNombreRubro(String NombreRubro) {
        this.NombreRubro = NombreRubro;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    private int id;
    private String NombreRubro;
    public Boolean Guardar() throws SQLException{
        String strcad="Insert into Rubro values(#id,'#NombreRubro')";
        strcad=strcad.replace("#id",Integer.toString(this.getId()));
        strcad=strcad.replace("#NombreRubro",this.getNombreRubro()); 
        return  this.ejecutar(strcad);
    }
    public Boolean Modificar() throws SQLException{
        String strcad="update rubro set NombreRubro='#NombreRubro' where id=#id";
        strcad=strcad.replace("#id",Integer.toString(this.getId()));
        strcad=strcad.replace("#NombreRubro",this.getNombreRubro()); 
        return  this.ejecutar(strcad);
    }
    
     public Boolean Eliminar() throws SQLException{
        String strcad="delete from rubro  where id=#id";
        strcad=strcad.replace("#id",Integer.toString(this.getId()));
        return  this.ejecutar(strcad);
    }
     public ResultSet TraerRubro() throws SQLException{
         if(this.id ==0){
            return this.seleccionar("select * from Rubro");
         }
         else{
             return this.seleccionar("select * from Rubro where id="+Integer.toString(this.getId()));
         }
     }
}
